﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using TakeoutExpress.Support;
using TakeoutExpress.Support.Linq;
using TakeoutExpress.Support.Controllers;



namespace TakeoutExpress2008.Web.MVC.MasterPages
{
	public partial class TakeoutExpressStandard : System.Web.UI.MasterPage
	{

        public event EventHandler<EventArgs> LoggedIn;
		protected void Page_Load(object sender, EventArgs e)
		{
            if (!Page.IsPostBack)
            {
                PopulateSites();
            }
		}


        protected void OnLoggedIn(object sender, EventArgs e)
        {

        }
        private void PopulateSites()
        {
            DropDownList ddlSites = (DropDownList)lvSiteAdmin.FindControl("ddlCurrentSite");
            SiteController controller = new SiteController();
            if (ddlSites != null)
            {
                ddlSites.AutoPostBack = true;
                ddlSites.SelectedIndexChanged += new EventHandler(ddlSites_SelectedIndexChanged);
                ddlSites.DataSource = controller.GetAllSites();
                ddlSites.DataTextField = "SiteName";
                ddlSites.DataValueField = "SiteID";
                ddlSites.DataBind();
                if (Session["currentSiteId"] != null)
                {
                    ddlSites.SelectedValue = Session["currentSiteId"].ToString();
                }
            }

        }

        void ddlSites_SelectedIndexChanged(object sender, EventArgs e)
        {
            Session["currentSiteId"] = ((DropDownList)sender).SelectedValue;
        }
    }

    
}
